package com.wxg.utils;

import java.io.File;
import java.util.HashSet;
import java.util.Set;

/**
 * Add : 2018-2-5
 * 将临时文件的filepath存储起来,以便于在某一个时刻将它们删除
 * 
 * @author Wxg
 *
 */
public class TempFileUtils {

	private static Set<String> tempFilepathList = null;
	
	public TempFileUtils(){
		if(null == tempFilepathList){
			tempFilepathList = new HashSet<String>();
		}
	}
	
	public void add(String filepath){
		tempFilepathList.add(filepath);
	}
	
	public synchronized void clear(){
		File file = null;
		for(String str : tempFilepathList){
			file = new File(str);
			if(null != file){
				file.delete();
			}
		}
		tempFilepathList = null;
		tempFilepathList = new HashSet<String>();
	}
	
}
